import java.util.Scanner;

public class Solution {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] nums = new int[n];
		int[] p = new int[n];
		
		int purse = 0;
		for (int i = 0; i < n; i++) {
			nums[i] = scanner.nextInt();
			purse += nums[i];
			p[i] = purse;
		}
		
		while (scanner.hasNextInt()){
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			
			int sum;
			if(a == 0){
				sum = p[b];
			}
			else {
				sum = p[b] - p[a-1];
			}
			System.out.println(sum);
		}
		scanner.close();
	}
}
